package ioProcessor;

import entities.AcdcProgram;
import entities.Course;

public class ProgramInputProcessor {
	
	public void processProgramData(String input) {
		//split the string
		String[] datas=input.split("\t");
		String courseCode=datas[0];
		String programArr=datas[1];
		String[] programs=programArr.split(",");
		
		int programsNum=0;
		while (programsNum < programs.length)
		{
			AcdcProgram program=AcdcProgram.getProgramByCode(programs[programsNum]);
			if (program==null)
			{	program=new AcdcProgram(programs[programsNum]);		
			}
			programsNum++;
		}	
		//new course
		Course theCourse=Course.getCourseByCode(courseCode);
		try {
			if (theCourse==null)
				theCourse=new Course(courseCode,programs);
			else
				throw (new Exception("This Course already exists!"));
		} catch(Exception e) {
			
		}
		
	}
}
